//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.example.service;

import cn.hutool.core.util.StrUtil;
import com.example.entity.Account;
import com.example.entity.Department;
import com.example.exception.CustomException;
import com.example.mapper.DepartmentMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;

@Service
public class DepartmentService {
    @Resource
    private DepartmentMapper departmentMapper;

    public DepartmentService() {
    }

    public void add(Department department) {
                this.departmentMapper.insert(department);
    }

    public void updateById(Department department) {
        this.departmentMapper.updateById(department);
    }

    public void deleteById(Integer id) {
        this.departmentMapper.deleteById(id);
    }

    public void deleteBatch(List<Integer> ids) {
        Iterator var2 = ids.iterator();

        while(var2.hasNext()) {
            Integer id = (Integer)var2.next();
            this.deleteById(id);
        }

    }

    public Department selectById(Integer id) {
        return this.departmentMapper.selectById(id);
    }

    public List<Department> selectAll(Department department) {
        return this.departmentMapper.selectAll(department);
    }

    public List<Department> selectList(Department department) {
        System.out.println(department);
        return null;
    }

    public PageInfo<Department> selectPage(Department department, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Department> list = this.departmentMapper.selectAll(department);
        return PageInfo.of(list);
    }

}
